import '_base_export.dart';
import '_view_export.dart';

class WebView extends StatefulWidget {
  final String url;
  const WebView({Key? key,required this.url}) : super(key: key);
  @override
  _WebViewState createState() => _WebViewState();
}

class _WebViewState extends State<WebView> {
  final flutterWebviewPlugin = FlutterWebviewPlugin();

  void initState() {
    super.initState();

    flutterWebviewPlugin.close();
    flutterWebviewPlugin.onDestroy.listen((_) {
      if (Navigator.canPop(context)) {
        Navigator.of(context).pop();
      }
    });
  }

  @override
  void dispose() {
    // Every listener should be canceled, the same should be done with this stream.
    flutterWebviewPlugin.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return WebviewScaffold(
      url: Uri.decodeQueryComponent(widget.url), //'www.google.com', //,this.url,
      appBar: new AppBar(
        brightness: Brightness.light,
        leading: GestureDetector(
          behavior: HitTestBehavior.opaque,
          onTap: () {
            Navigator.pop(context);
          },
          child: Container(
            child: Icon(
              Icons.chevron_left,
              color: AppColor.blackMain,
              size: 32,
            ),
          ),
        ),
        title: new Text(""),
      ),
      hidden: true,
    );
  }
}
